#include "stdafx.h"
#include "wf_selectall.h"
#include "pf_selection.h"

WF_SelectAll::WF_SelectAll(PF_Container& container,
                                       PF_GraphicView& graphicView,
                                       bool select)
        :PF_ActionInterface("Select All Entities",
                    container, graphicView) {

    this->select = select;
}

QAction* WF_SelectAll::createGUIAction(LX_Define::ActionType type, QObject* parent) {
    QAction* action;
    if (type==LX_Define::ActionSelectAll) {
		// tr("Select All")
                action = new QAction(tr("Select &All"), parent);
                action->setShortcut(QKeySequence::SelectAll);
                action->setIcon(QIcon(":/extui/selectall.png"));
                //action->zetStatusTip(tr("Selects all Entities"));
	} else {
		// tr("Deselect all")
		action = new QAction(tr("Deselect &all"), parent);
                //   April 29, 2011 - Added esc key to de-select all entities
                action->setShortcuts(QList<QKeySequence>() << QKeySequence(tr("Ctrl+K")));
                action->setIcon(QIcon(":/extui/selectnothing.png"));
                //action->zetStatusTip(tr("Deselects all Entities"));
    }
    return action;
}


void WF_SelectAll::init(int status) {
    PF_ActionInterface::init(status);
    trigger();
    finish();
}

void WF_SelectAll::trigger() {
    PF_Selection s(*container, graphicView);
    s.selectAll(select);

    PF_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
}

// EOF
